﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Interface.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	MethodWorx CMS
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <style>
        li.contextMenuItem.selected
        {
            background-color:White;
            padding:6px;
            font-weight:bold;
            cursor:default;
        }
        
        li.contextMenuItem
        {
            background-color:#dddddd;
            padding:6px;
            cursor:pointer;
        }
        
         li.contextMenuItemDisabled
        {
            background-color:#dddddd;
            color:#aaaaaa;
            padding:6px;
            cursor:default;
        }
        
        #pleaseWait
        {
            width:200px;
            height:80px;
            background-color:White;
            border:2px solid gray;
            text-align:center;
            position:absolute;
            z-index:999999;
            top: 50%;
            left: 50%;
            margin-left: -100px;
            margin-top: -50px;
            padding:20px;
            font-size:12pt;
        }
        
        #previewPopup
        {
            border:2px solid gray;
            text-align:center;
            position:absolute;
            z-index:999999;
            top:50%;
            left:50%;
            font-size:12pt;
        }
    </style>

    <script language="javascript">
        var baseUrl = '<%= this.ViewData["baseUrl"]%>';

        function refreshCurrentNode(parent)
        {
            window.frames['contentFrame'].refreshCurrentNode(parent);
        }

        function renameCurrentNode(action)
        {
            window.frames['contentFrame'].renameCurrentNode(action);
        }
        var onDialogClose;

        function showPleaseWait()
        {
            if($("#pleaseWait").length == 0)
            {
                $("body").append("<div id=\"pleaseWait\">Please Wait...<p><img src=\"<%=Url.Content("~/images/bigrotation2.gif")%>\"/></p></div>");
            }
        }

        function hidePleaseWait()
        {
            $("#pleaseWait").remove();
        }

        function showPreview(url)
        {
            if($("#previewPopup").length == 0)
            {
                $("body").append("<img id=\"previewPopup\" style=\"display:none\" src=\"" + url + "\"/>");
                $("#previewPopup").ready(function()
                {
                    $("#previewPopup").css("margin-left", "-" + ($("#previewPopup").width() / 2) + "px");
                    $("#previewPopup").css("margin-top", "-" + ($("#previewPopup").height() / 2) + "px");
                    $("#previewPopup").fadeIn();
                });
            }
        }

        $(document).click(function()
        {
            hidePreview();
        });

        function hidePreview()
        {
            $("#previewPopup").remove();
        }
        

        function openDialog(src, title, onclose) {
            onDialogClose = onclose

            var $dialog = $("<div id=\"dialog\"></div>")
                .html("<iframe style=\"width:100%;height:100%;border:none\" src=\"" + src + "\"></iframe>")
                .dialog({
                    autoOpen: false,
                    title: title,
                    width: 600,
                    height:450,
                    modal:true,
                    resizable:false,
                });

                $dialog.dialog('open');
                return false;
            }

        function closeDialog(action)
        {
            $("#dialog").dialog("close");
            $("#dialog").remove();

            if(onDialogClose != null)
                onDialogClose(action);
        }

        function refreshContent()
        {
            $("#contentFrame").attr("src", $("#contentFrame").attr("src"));
        }

        

        function resizeUi() {
            $(".tabArea").height($(window).height() - 100);
            
        }

        $(document).ready(function () {
            $("button").button();
            $("input[type='submit']").button();

            $("#accordion").accordion();

            $(window).resize(function () {
                resizeUi();
            });

            resizeUi();
        });

        function clearContextMenu(menu) {
            $("#contextMenu" + menu).html("");
        }

        

        function setContextMenu(items, menu) {
        
            var i = 0;
            var s = "";
            for (i = 0; i < items.length; i++) {
                if (items[i].enabled != false) {
                    s += "<li class=\"contextMenuItem\">" + items[i].name + "</li>";
                }
                else
                    s += "<li class=\"contextMenuItemDisabled\">" + items[i].name + "</li>";
            }

            $("#contextMenu" + menu).html(s);

            $("#contextMenu" + menu + " li:first-child").addClass("selected");

            $("#contextFrame" + menu).attr("src", items[0].src);

            bindContextMenuEvents(items, menu);
        }


        function bindContextMenuEvents(items, menu) {
            $("#contextMenu" + menu).children("li.contextMenuItem").each(function (i, e) {
                $(e).unbind("click");
                if (!$(e).hasClass("selected")) {
                    $(e).click(function () {
                        $("#contextMenu" + menu).children("li.contextMenuItem").removeClass("selected");
                        $(e).addClass("selected");

                        $("#contextFrame" + menu).attr("src", items[i].src);

                        bindContextMenuEvents(items, menu);
                    });
                }
            });                
        }

        $(document).ready(function()
        {
            setupAdminMenu();
        });


        



        function setupAdminMenu()
        {
            var items = new Array();
            items.push({ name: "Overview", src: "<%=Url.Content("~/Administration")%>"});
            items.push({ name: "Export", src: "<%=Url.Content("~/Administration/Export")%>"});
            items.push({ name: "Plugins", src: "<%=Url.Content("~/Administration/Plugins")%>"});
            items.push({ name: "Users", src: "<%=Url.Content("~/Administration")%>/User?usertype=SiteUser"});
            items.push({ name: "Members", src: "<%=Url.Content("~/Administration")%>/User?usertype=SiteMember"});
            setContextMenu(items, "Admin");
        }
              

    </script>
    <div id="tabs" style="height:100%">
       <iframe class="tabArea" id="tabs-1" style="border:none;height:100%;" src="<%=Url.Content("~/DashboardContainer/Index")%>">
       </iframe>
       <div class="tabArea" id="tabs-2" style="height:100%;display:none">
         <iframe src="<%=Url.Content("~/Content/Index")%>" style="width:100%;height:100%;border:none" id="contentFrame" name="contentFrame">
         </iframe>
       </div>
       <!-- Administration tab -->
       <div class="tabArea" id="tabs-3" style="height:100%;display:none">
         <table style="width:100%;height:100%;">
            <tr style="height:100%">
                <td  style="width:100%;height:100%;border:1px solid silver;padding:0px;margin:0px;">
                    <table style="height:100%;width:100%;">
                        <tr style="height:100%;">
                            <td style="width:150px;background-color:#dddddd;height:100%;vertical-align:top;padding:0px;">
                                <ul style="list-style-type:none" id="contextMenuAdmin">
                                    
                                </ul>
                            </td>
                            <td style="height:100%">
                                <iframe src="<%=Url.Content("~/Administration")%>" style="width:100%;height:100%;border:none" id="contextFrameAdmin">
                                </iframe>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
       </div>
</div>


</asp:Content>
